
package Pro;


public class convert {
   // Ham nay jup chuyen doi qua lai vi tri, giua jtable voi vi tri minh dinh nghia ra
    //Conver position of cell of table to number
    // List input : Row ,  Column , type = 4 or 6
    public static int table_to_number(int row, int col, int type)
    {
        int result=0;
        if(type==6)
        {
            
            col++;
            result=(row*6)+col;
        }else
        {
            
            col++;
            result=(row*4)+col;
        }
        return result;
    }
    //Conver number to position of cell of table
    // List input : number to convet, type= 4 or 6
    //return int[2] int[0] is row int[1] in column
    public static int[] number_to_table(int num, int type)
    {
        num--;
        int[] res=new int[2];
        if(type==6)
        {
            res[0]=num/6;
            res[1]=num%6;
        }else
        {
            res[0]=num/4;
            res[1]=num%4;
        }
        return res;
    }

}
